var year =2019;
var mounth = 5;

document.querySelector("#nian").innerHTML = year;
document.querySelector("#yue").innerHTML = mounth;

//*判断平闰年
function runNian(y){
    if(y % 400 === 0 ||(y % 4 === 0 && y % 100 !==0)){
        return true;
    }else{
        return false;
    }
}
//*算1980-2018年底的总天数
for(var i = 1980;i<year;i++){
    if(runNian(i)){
        days += 366;
    }else{
        days += 365;
    }
}

//*判断算出今年1月到4月的天数
for(var k =1; k = mounth;k++){
    switch(k){
        case 1:
            days += 31;
            break;
        case 2:
            if(runNian(year)){
            days += 29;
            }else{
            days += 28;
            }
            break;
        case 3:
            days += 31;
            break;
        case 4:
            days += 30;
            break;
        case 5:
            days += 31;
            break;
        case 6:
            days += 30;
            break;
        case 7:
            days += 31;
            break;
        case 8:
            days += 31;
            break;
        case 9:
            days += 30;
            break;
        case 10:
            days += 31;
            break;
        case 11:
            days += 30;
            break;
        case 12:
            days += 31;
            break;
    }
}


//*算出本月的天数，判断平闰年
var day = 0;
switch (mounth){
    case 1:
        day += 31;
        break;
    case 2:
        if(runNian(year)){
            day += 29;
        }else{
            day += 28;
        }
        break;
    case 3:
        day += 31;
        break;
    case 4:
        day += 30;
        break;
    case 5:
        day += 31;
        break;
    case 6:
        day += 30;
        break;
    case 7:
        day += 31;
        break;
    case 8:
        day += 31;
        break;
    case 9:
        day += 30;
        break;
    case 10:
        day += 31;
        break;
    case 11:
        day += 30;break;
    case 12:
        day += 31;
        break;
}
console.log(day);

//*上个月一共有多少天
var ktDay = 0;
switch (mounth - 1){
    case 1:
        ktDay += 31;
        break;
    case 2:
        if(runNian(year)){
            ktDay += 29;
        }else{
            ktDay += 28;
        }
        break;
    case 3:
        ktDay += 31;
        break;
    case 4:
        ktDay += 30;
        break;
    case 5:
        ktDay += 31;
        break;
    case 6:
        ktDay += 30;
        break;
    case 7:
        ktDay += 31;
        break;
    case 8:
        ktDay += 31;
        break;
    case 9:
        ktDay += 30;
        break;
    case 10:
        ktDay += 31;
        break;
    case 11:
        ktDay += 30;
        break;
    case 12:
        ktDay += 31;
        break;
}
console.log(ktDay);

//*1980的1月1日是星期二，以周日开始计算
date +=2;
console.log(days);

//*本月1日是星期几
var start = day % 7;
console.log(start);

//*页面一共有多少天
var num = 42;

//*算出下个月的天数

var nextDays = num -start -day;

//*三个复循环
var thisdate = new Date().getDate();
var date1 =document.querySelector("#date1");

for(var j = ktDay -start +1;j<=ktDay;j++){
    date1.innerHTML += "<span class='h'>" +j+ "</span>";
}
for(var a =1;a<=day;a++){
    if(a ==thisdate){
        date1.innerHTML += "<span class='today'>" +a+ "</span>";
    }else{
        date1.innerHTML += "<span>" +a+ "</span>";
    }
}
for(var s =1;s<=nextDays;s++){
    date1.innerHTML += "<span class='h'>" +s+ "</span>";
}